import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import render from "@feidao/web/atom/browser/render/render";
import nodejs from "@feidao/web/atom/browser/msg/nodejs";
import { Params } from '../atom/params2query';
import p2q from '../atom/params2query';
import P04 from './P04';
import P03 from './P03';

export default async function a010(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 刷新当前列表
	let page_no = fd.data.params['page-no'];
	if (!page_no) {
		page_no = 1;
	}
	let page_size = fd.data.params['page_size'];
	if (!page_size) {
		page_size = 20;
	}
	const q = p2q(fd.data.params as Params);
	if (Object.keys(fd.data.params.order).length === 0) {
		q.sort = { enterdate: -1 };
	}
	const query = {
		filter: q.criteria,
		sort: q.sort,
		page_no,
		page_size
	};// 没有数据
	const res = await nodejs(fd.data.spaceid, "certifi_info_find", query);
	// 无数据渲染P04
	if (res.dataArray.length == 0) {
		render(fd, '', P04, 'P04', 'inner');
	} else {
		render(fd, res.dataArray, P03, 'P03', 'inner');
	}
}
